home *** CD-ROM | disk | FTP | other *** search
/ Inter.Net 55-1 / Inter.Net 55-1.iso / CBuilder / Setup / BCB / data.z / httpfilt.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-02-09  |  12.8 KB  |  488 lines

  1. /*++
  2.  
  3. Copyright (c) 1995-1996  Microsoft Corporation
  4.  
  5. Module Name:
  6.  
  7.     httpfilt.h
  8.  
  9. Abstract:
  10.  
  11.     This module contains the Microsoft HTTP filter extension info
  12.  
  13. Revision History:
  14.  
  15. --*/
  16.  
  17. /*
  18.  *      C/C++ Run Time Library - Version 9.0
  19.  *
  20.  *      Copyright (c) 1997, 1998 by Borland International
  21.  *      All Rights Reserved.
  22.  *
  23.  */
  24.  
  25. #ifndef _HTTPFILT_H_
  26. #define _HTTPFILT_H_
  27. #pragma option push -b
  28.  
  29. #include <pshpack4.h>
  30.  
  31.  
  32.  
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36.  
  37. //
  38. //  Current version of the filter spec is 2.0
  39. //
  40.  
  41. #define HTTP_FILTER_REVISION    MAKELONG( 0, 2);
  42.  
  43. #define SF_MAX_USERNAME         (256+1)
  44. #define SF_MAX_PASSWORD         (256+1)
  45.  
  46. #define SF_MAX_FILTER_DESC_LEN  (256+1)
  47.  
  48. //
  49. //  These values can be used with the pfnSFCallback function supplied in
  50. //  the filter context structure
  51. //
  52.  
  53. enum SF_REQ_TYPE
  54. {
  55.     //
  56.     //  Sends a complete HTTP server response header including
  57.     //  the status, server version, message time and MIME version.
  58.     //
  59.     //  Server extensions should append other information at the end,
  60.     //  such as Content-type, Content-length etc followed by an extra
  61.     //  '\r\n'.
  62.     //
  63.     //  pData - Zero terminated string pointing to optional
  64.     //      status string (i.e., "401 Access Denied") or NULL for
  65.     //      the default response of "200 OK".
  66.     //
  67.     //  ul1 - Zero terminated string pointing to optional data to be
  68.     //      appended and set with the header.  If NULL, the header will
  69.     //      be terminated with an empty line.
  70.     //
  71.  
  72.     SF_REQ_SEND_RESPONSE_HEADER,
  73.  
  74.     //
  75.     //  If the server denies the HTTP request, add the specified headers
  76.     //  to the server error response.
  77.     //
  78.     //  This allows an authentication filter to advertise its services
  79.     //  w/o filtering every request.  Generally the headers will be
  80.     //  WWW-Authenticate headers with custom authentication schemes but
  81.     //  no restriction is placed on what headers may be specified.
  82.     //
  83.     //  pData - Zero terminated string pointing to one or more header lines
  84.     //      with terminating '\r\n'.
  85.     //
  86.  
  87.     SF_REQ_ADD_HEADERS_ON_DENIAL,
  88.  
  89.     //
  90.     //  Only used by raw data filters that return SF_STATUS_READ_NEXT
  91.     //
  92.     //  ul1 - size in bytes for the next read
  93.     //
  94.  
  95.     SF_REQ_SET_NEXT_READ_SIZE,
  96.  
  97.     //
  98.     //  Used to indicate this request is a proxy request
  99.     //
  100.     //  ul1 - The proxy flags to set
  101.     //      0x00000001 - This is a HTTP proxy request
  102.     //
  103.     //
  104.  
  105.     SF_REQ_SET_PROXY_INFO,
  106.  
  107.     //
  108.     //  Returns the connection ID contained in the ConnID field of an
  109.     //  ISAPI Application's Extension Control Block.  This value can be used
  110.     //  as a key to cooridinate shared data between Filters and Applications.
  111.     //
  112.     //  pData - Pointer to DWORD that receives the connection ID.
  113.     //
  114.  
  115.     SF_REQ_GET_CONNID
  116. };
  117.  
  118.  
  119. //
  120. //  These values are returned by the filter entry point when a new request is
  121. //  received indicating their interest in this particular request
  122. //
  123.  
  124. enum SF_STATUS_TYPE
  125. {
  126.     //
  127.     //  The filter has handled the HTTP request.  The server should disconnect
  128.     //  the session.
  129.     //
  130.  
  131.     SF_STATUS_REQ_FINISHED = 0x8000000,
  132.  
  133.     //
  134.     //  Same as SF_STATUS_FINISHED except the server should keep the TCP
  135.     //  session open if the option was negotiated
  136.     //
  137.  
  138.     SF_STATUS_REQ_FINISHED_KEEP_CONN,
  139.  
  140.     //
  141.     //  The next filter in the notification chain should be called
  142.     //
  143.  
  144.     SF_STATUS_REQ_NEXT_NOTIFICATION,
  145.  
  146.     //
  147.     //  This filter handled the notification.  No other handles should be
  148.     //  called for this particular notification type
  149.     //
  150.  
  151.     SF_STATUS_REQ_HANDLED_NOTIFICATION,
  152.  
  153.     //
  154.     //  An error occurred.  The server should use GetLastError() and indicate
  155.     //  the error to the client
  156.     //
  157.  
  158.     SF_STATUS_REQ_ERROR,
  159.  
  160.     //
  161.     //  The filter is an opaque stream filter and we're negotiating the
  162.     //  session parameters.  Only valid for raw read notification.
  163.     //
  164.  
  165.     SF_STATUS_REQ_READ_NEXT
  166. };
  167.  
  168. //
  169. //  pvNotification points to this structure for all request notification types
  170. //
  171.  
  172. typedef struct _HTTP_FILTER_CONTEXT
  173. {
  174.     DWORD          cbSize;
  175.  
  176.     //
  177.     //  This is the structure revision level.
  178.     //
  179.  
  180.     DWORD          Revision;
  181.  
  182.     //
  183.     //  Private context information for the server.
  184.     //
  185.  
  186.     PVOID          ServerContext;
  187.     DWORD          ulReserved;
  188.  
  189.     //
  190.     //  TRUE if this request is coming over a secure port
  191.     //
  192.  
  193.     BOOL           fIsSecurePort;
  194.  
  195.     //
  196.     //  A context that can be used by the filter
  197.     //
  198.  
  199.     PVOID          pFilterContext;
  200.  
  201.     //
  202.     //  Server callbacks
  203.     //
  204.  
  205.     BOOL (WINAPI * GetServerVariable) (
  206.         struct _HTTP_FILTER_CONTEXT * pfc,
  207.         LPSTR                         lpszVariableName,
  208.         LPVOID                        lpvBuffer,
  209.         LPDWORD                       lpdwSize
  210.         );
  211.  
  212.     BOOL (WINAPI * AddResponseHeaders) (
  213.         struct _HTTP_FILTER_CONTEXT * pfc,
  214.         LPSTR                         lpszHeaders,
  215.         DWORD                         dwReserved
  216.         );
  217.  
  218.     BOOL (WINAPI * WriteClient)  (
  219.         struct _HTTP_FILTER_CONTEXT * pfc,
  220.         LPVOID                        Buffer,
  221.         LPDWORD                       lpdwBytes,
  222.         DWORD                         dwReserved
  223.         );
  224.  
  225.     VOID * (WINAPI * AllocMem) (
  226.         struct _HTTP_FILTER_CONTEXT * pfc,
  227.         DWORD                         cbSize,
  228.         DWORD                         dwReserved
  229.         );
  230.  
  231.     BOOL (WINAPI * ServerSupportFunction) (
  232.         struct _HTTP_FILTER_CONTEXT * pfc,
  233.         enum SF_REQ_TYPE              sfReq,
  234.         PVOID                         pData,
  235.         DWORD                         ul1,
  236.         DWORD                         ul2
  237.         );
  238.  
  239. } HTTP_FILTER_CONTEXT, *PHTTP_FILTER_CONTEXT;
  240.  
  241. //
  242. //  This structure is the notification info for the read and send raw data
  243. //  notification types
  244. //
  245.  
  246. typedef struct _HTTP_FILTER_RAW_DATA
  247. {
  248.     //
  249.     //  This is a pointer to the data for the filter to process.
  250.     //
  251.  
  252.     PVOID         pvInData;
  253.     DWORD         cbInData;       // Number of valid data bytes
  254.     DWORD         cbInBuffer;     // Total size of buffer
  255.  
  256.     DWORD         dwReserved;
  257.  
  258. } HTTP_FILTER_RAW_DATA, *PHTTP_FILTER_RAW_DATA;
  259.  
  260. //
  261. //  This structure is the notification info for when the server is about to
  262. //  process the client headers
  263. //
  264.  
  265. typedef struct _HTTP_FILTER_PREPROC_HEADERS
  266. {
  267.     //
  268.     //  Retrieves the specified header value.  Header names should include
  269.     //  the trailing ':'.  The special values 'method', 'url' and 'version'
  270.     //  can be used to retrieve the individual portions of the request line
  271.     //
  272.  
  273.     BOOL (WINAPI * GetHeader) (
  274.         struct _HTTP_FILTER_CONTEXT * pfc,
  275.         LPSTR                         lpszName,
  276.         LPVOID                        lpvBuffer,
  277.         LPDWORD                       lpdwSize
  278.         );
  279.  
  280.     //
  281.     //  Replaces this header value to the specified value.  To delete a header,
  282.     //  specified a value of '\0'.
  283.     //
  284.  
  285.     BOOL (WINAPI * SetHeader) (
  286.         struct _HTTP_FILTER_CONTEXT * pfc,
  287.         LPSTR                         lpszName,
  288.         LPSTR                         lpszValue
  289.         );
  290.  
  291.     //
  292.     //  Adds the specified header and value
  293.     //
  294.  
  295.     BOOL (WINAPI * AddHeader) (
  296.         struct _HTTP_FILTER_CONTEXT * pfc,
  297.         LPSTR                         lpszName,
  298.         LPSTR                         lpszValue
  299.         );
  300.  
  301.     DWORD dwReserved;
  302. } HTTP_FILTER_PREPROC_HEADERS, *PHTTP_FILTER_PREPROC_HEADERS;
  303.  
  304. //
  305. //  Authentication information for this request.
  306. //
  307.  
  308. typedef struct _HTTP_FILTER_AUTHENT
  309. {
  310.     //
  311.     //  Pointer to username and password, empty strings for the anonymous user
  312.     //
  313.     //  Client's can overwrite these buffers which are guaranteed to be at
  314.     //  least SF_MAX_USERNAME and SF_MAX_PASSWORD bytes large.
  315.     //
  316.  
  317.     CHAR * pszUser;
  318.     DWORD  cbUserBuff;
  319.  
  320.     CHAR * pszPassword;
  321.     DWORD  cbPasswordBuff;
  322.  
  323. } HTTP_FILTER_AUTHENT, *PHTTP_FILTER_AUTHENT;
  324.  
  325. //
  326. //  Indicates the server is going to use the specific physical mapping for
  327. //  the specified URL.  Filters can modify the physical path in place.
  328. //
  329.  
  330. typedef struct _HTTP_FILTER_URL_MAP
  331. {
  332.     const CHAR * pszURL;
  333.  
  334.     CHAR *       pszPhysicalPath;
  335.     DWORD        cbPathBuff;
  336.  
  337. } HTTP_FILTER_URL_MAP, *PHTTP_FILTER_URL_MAP;
  338.  
  339. //
  340. //  Bitfield indicating the requested resource has been denied by the server due
  341. //  to a logon failure, an ACL on a resource, an ISAPI Filter or an
  342. //  ISAPI Application/CGI Application.
  343. //
  344. //  SF_DENIED_BY_CONFIG can appear with SF_DENIED_LOGON if the server
  345. //  configuration did not allow the user to logon.
  346. //
  347.  
  348. #define SF_DENIED_LOGON             0x00000001
  349. #define SF_DENIED_RESOURCE          0x00000002
  350. #define SF_DENIED_FILTER            0x00000004
  351. #define SF_DENIED_APPLICATION       0x00000008
  352.  
  353. #define SF_DENIED_BY_CONFIG         0x00010000
  354.  
  355. typedef struct _HTTP_FILTER_ACCESS_DENIED
  356. {
  357.     const CHAR * pszURL;            // Requesting URL
  358.     const CHAR * pszPhysicalPath;   // Physical path of resource
  359.     DWORD        dwReason;          // Bitfield of SF_DENIED flags
  360.  
  361. } HTTP_FILTER_ACCESS_DENIED, *PHTTP_FILTER_ACCESS_DENIED;
  362.  
  363. //
  364. //  The log information about to be written to the server log file.  The
  365. //  string pointers can be replaced but the memory must remain valid until
  366. //  the next notification
  367. //
  368.  
  369. typedef struct _HTTP_FILTER_LOG
  370. {
  371.     const CHAR * pszClientHostName;
  372.     const CHAR * pszClientUserName;
  373.     const CHAR * pszServerName;
  374.     const CHAR * pszOperation;
  375.     const CHAR * pszTarget;
  376.     const CHAR * pszParameters;
  377.  
  378.     DWORD  dwHttpStatus;
  379.     DWORD  dwWin32Status;
  380.  
  381. } HTTP_FILTER_LOG, *PHTTP_FILTER_LOG;
  382.  
  383. //
  384. //  Notification Flags
  385. //
  386. //  SF_NOTIFY_SECURE_PORT
  387. //  SF_NOTIFY_NONSECURE_PORT
  388. //
  389. //      Indicates whether the application wants to be notified for transactions
  390. //      that are happenning on the server port(s) that support data encryption
  391. //      (such as PCT and SSL), on only the non-secure port(s) or both.
  392. //
  393. //  SF_NOTIFY_READ_RAW_DATA
  394. //
  395. //      Applications are notified after the server reads a block of memory
  396. //      from the client but before the server does any processing on the
  397. //      block.  The data block may contain HTTP headers and entity data.
  398. //
  399. //
  400. //
  401.  
  402. #define SF_NOTIFY_SECURE_PORT               0x00000001
  403. #define SF_NOTIFY_NONSECURE_PORT            0x00000002
  404.  
  405. #define SF_NOTIFY_READ_RAW_DATA             0x00008000
  406. #define SF_NOTIFY_PREPROC_HEADERS           0x00004000
  407. #define SF_NOTIFY_AUTHENTICATION            0x00002000
  408. #define SF_NOTIFY_URL_MAP                   0x00001000
  409. #define SF_NOTIFY_ACCESS_DENIED             0x00000800
  410. #define SF_NOTIFY_SEND_RAW_DATA             0x00000400
  411. #define SF_NOTIFY_LOG                       0x00000200
  412. #define SF_NOTIFY_END_OF_NET_SESSION        0x00000100
  413.  
  414. //
  415. //  Filter ordering flags
  416. //
  417. //  Filters will tend to be notified by their specified
  418. //  ordering.  For ties, notification order is determined by load order.
  419. //
  420. //  SF_NOTIFY_ORDER_HIGH - Authentication or data transformation filters
  421. //  SF_NOTIFY_ORDER_MEDIUM
  422. //  SF_NOTIFY_ORDER_LOW  - Logging filters that want the results of any other
  423. //                      filters might specify this order.
  424. //
  425.  
  426. #define SF_NOTIFY_ORDER_HIGH               0x00080000
  427. #define SF_NOTIFY_ORDER_MEDIUM             0x00040000
  428. #define SF_NOTIFY_ORDER_LOW                0x00020000
  429. #define SF_NOTIFY_ORDER_DEFAULT            SF_NOTIFY_ORDER_LOW
  430.  
  431. #define SF_NOTIFY_ORDER_MASK               (SF_NOTIFY_ORDER_HIGH   |    \
  432.                                             SF_NOTIFY_ORDER_MEDIUM |    \
  433.                                             SF_NOTIFY_ORDER_LOW)
  434.  
  435. //
  436. //  Filter version information, passed to GetFilterVersion
  437. //
  438.  
  439. typedef struct _HTTP_FILTER_VERSION
  440. {
  441.     //
  442.     //  Version of the spec the server is using
  443.     //
  444.  
  445.     DWORD  dwServerFilterVersion;
  446.  
  447.     //
  448.     //  Fields specified by the client
  449.     //
  450.  
  451.     DWORD  dwFilterVersion;
  452.     CHAR   lpszFilterDesc[SF_MAX_FILTER_DESC_LEN];
  453.     DWORD  dwFlags;
  454.  
  455.  
  456. } HTTP_FILTER_VERSION, *PHTTP_FILTER_VERSION;
  457.  
  458. //
  459. //  A filter DLL's entry point looks like this.  The return code should be
  460. //  an SF_STATUS_TYPE
  461. //
  462. //  NotificationType - Type of notification
  463. //  pvNotification - Pointer to notification specific data
  464. //
  465.  
  466. DWORD
  467. WINAPI
  468. HttpFilterProc(
  469.     HTTP_FILTER_CONTEXT *      pfc,
  470.     DWORD                      NotificationType,
  471.     VOID *                     pvNotification
  472.     );
  473.  
  474. BOOL
  475. WINAPI
  476. GetFilterVersion(
  477.     HTTP_FILTER_VERSION * pVer
  478.     );
  479.  
  480. #ifdef __cplusplus
  481. }
  482. #endif
  483.  
  484. #include <poppack.h>
  485.  
  486. #pragma option pop
  487. #endif //_HTTPFILT_H_
  488.